package hardestWorker;

public class Solution {
    public int hardestWorker(int n, int[][] logs) {
        int startTime = 0;
        int maxTime = 0;
        int id = 0;
        for (int i = 0; i < logs.length; i++) {
            int time = logs[i][1] - startTime;
            if(time>maxTime) {
                maxTime = time;
                id = logs[i][0];
            }else if(time == maxTime) {
                id = Math.min(id,logs[i][0]);
            }
            startTime = logs[i][1];
        }
        return id;
    }
}
